package com.gmail.bogatyr.alexander.server.manager;

import com.gmail.bogatyr.alexander.server.dao.ITelephoneBookDao;
import com.google.inject.Inject;
import com.google.inject.persist.Transactional;
import com.gmail.bogatyr.alexander.server.dao.TelephoneBookDao;
import com.gmail.bogatyr.alexander.shared.entity.TelephoneBook;

import java.util.List;

public class TelephoneBookManager implements ITelephoneBookManager {

    @Inject
    private ITelephoneBookDao telephoneBookDao;
    
    @Override
    @Transactional
    public List<TelephoneBook> find(String number, String name) {
        return telephoneBookDao.find(number, name);
    }

    @Override
    @Transactional
    public List<TelephoneBook> findAll() {
        return telephoneBookDao.findAll();
    }

    @Override
    @Transactional
    public TelephoneBook save(TelephoneBook telephoneBook) {
        return telephoneBookDao.save(telephoneBook);
    }

    @Override
    @Transactional
    public TelephoneBook read(Long id) {
        return telephoneBookDao.getOne(id);
    }

    @Override
    @Transactional
    public TelephoneBook update(TelephoneBook telephoneBook) {
        return telephoneBookDao.save(telephoneBook);
    }

    @Override
    @Transactional
    public void delete(TelephoneBook telephoneBook) {
        telephoneBookDao.delete(telephoneBook);
    }
}
